<!DOCTYPE html>
<html lang="en"  xmlns:th="http://www.thymeleaf.org" >
<head>
  <title>用户登录</title>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css">
  <style>
    body {
      background-color: #11A1FD;
    }
    .login-container {
      width: 500px;
      margin: 0 auto;
      margin-top: 200px;
      padding: 20px;
      background-color: #fff;
      border: 1px solid #ccc;
      border-radius: 5px;
    }
    .login-container h2 {
      text-align: center;
      margin-bottom: 30px;
    }
    .login-container .form-group {
      margin-bottom: 15px;
    }
    .login-container .form-group button{
      width: 100px;
    }
    .login-container .form-group label {
      display: block;
      font-weight: bold;
    }
    .login-container .form-group input {
      width: 100%;
      padding: 5px;
      font-size: 16px;
      border-radius: 3px;
      border: 1px solid #ccc;
    }
    .login-container .form-group .error-message {
      color: red;
      font-size: 14px;
    }
    .login-container .form-group .admin-link {
      margin-top: 10px;
      text-align: right;
    }
  </style>
</head>
<body>
<div class="container">
  <div class="row justify-content-center">
    <div class="col-md-6">
      <div class="login-container">
        <h2>管理员登录</h2>
        <form action="" method="post" th:action="@{/author/admin/login.do}">
          <div class="form-group">
            <label for="email">邮箱:</label>
            <input type="email" id="email" name="userEmail" class="form-control" required>
            <span class="error-message" id="email-error"></span>
          </div>
          <div class="form-group">
            <label for="password">密码:</label>
            <input type="password" id="password" name="userPassword" class="form-control" required>
          </div>
          <div class="form-group">
            <button type="submit" class="btn btn-primary">登录</button>
          </div>
        </form>
        <p style="color: red" th:text="${msg}">1</p>
      </div>
    </div>
  </div>
</div>

<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.5.2/js/bootstrap.min.js"></script>
<script>
  const emailInput = document.getElementById('email');
  const emailError = document.getElementById('email-error');

  function validateEmail() {
    const email = emailInput.value;
    const regex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
    const valid = regex.test(email);

    if (!valid) {
      emailError.innerText = '您的账户格式格式并不正确';
    } else {
      emailError.innerText = '';
    }
  }
  emailInput.addEventListener('blur', validateEmail);
</script>
</body>
</html>
